package com.heima.comment.controller;

import com.heima.comment.service.CommentRepayService;
import com.heima.model.comment.dtos.CommentRepayDTO;
import com.heima.model.comment.dtos.CommentRepayLikeDTO;
import com.heima.model.comment.dtos.CommentRepaySaveDTO;
import com.heima.model.common.dtos.ResponseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


@Api(tags = "app端评论回复点赞", value = "app端评论回复点赞")
@RestController
@RequestMapping("/api/v1")
public class CommentRepayController {
    @Autowired
    CommentRepayService commentRepayService;

    //保存评论
    @PostMapping("/comment_repay/save")
    @ApiOperation("保存回复评论")
    public ResponseResult saveComment(@RequestBody @Validated CommentRepaySaveDTO dto) {
        return commentRepayService.saveCommentRepay(dto);
    }

    @ApiOperation(value = "评论回复点赞")
    @PostMapping("/comment_repay/like")
    public ResponseResult findByUserIdOrEquipmentId(@RequestBody @Validated CommentRepayLikeDTO dto) {
        return commentRepayService.saveCommentRepayLike(dto);
    }

    @ApiOperation(value = "加载回复评论")
    @PostMapping("/comment_repay/load")
    public ResponseResult findByArticleId(@RequestBody @Validated CommentRepayDTO dto) {
        return commentRepayService.loadCommentRepay(dto);
    }
}
